package org.example.util;


import com.example.fanqie.entity.Novel;
import org.springframework.beans.factory.annotation.Autowired;


import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;

import java.util.List;

//redis缓存工具类
@Component
public class RedisCacheUtil {

    @Autowired
    private RedisTemplate<String, Object> redisTemplate;

    public void saveSearchResult(  List<Novel> results) {
        String key = "search";
        redisTemplate.opsForValue().set(key, results);
    }

    public  List<Novel> getSearchResult( ) {
        String key = "search";
        return (List<Novel>) redisTemplate.opsForValue().get(key);
    }

}